﻿
function wxApiAuth(callback) {
    $.ajax({
        type: "GET",
        url: llb_global.config.wxapi + "ajax_h5_get_user_info",
        xhrFields: {
            withCredentials: true
        },
        async: false,
        success: function (data) {
            var jumpURL = llb_global.config.wxapi + "api_go_to_oauth&call_back=" + encodeURIComponent(window.location.href);
            if (data.err_code == -1002 || data.err_code == -1000) {
                window.location.href = jumpURL;
            } else if (data.err_code == 0) {
                if (typeof (callback) === "function") {
                    callback(data.data.openid);
                }
            } else {
                if (data.err_code == 100001)
                    alert("微信获取用户身份错误：接口所需参数错误");
                if (data.err_code == 100002)
                    alert("微信获取用户身份错误：openid为空");
            }
        },
        error: function (e) {
            //alert("登录账号错误");
        }
    });
}